<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>查看科目卷子</title>
		<meta name="renderer" content="webkit">
		<link rel="stylesheet" href="layui/css/layui%20-%20副本.css" media="all">
		<!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
		
		<script src="jquery/jquery-1.11.3.min.js" charset="UTF-8"></script>
		<style type="text/css">
			th {
				background-color: white;
				border-bottom: 3px solid #ebeef5;
			}

			/* .layui-table-page{ */
			td {
				border-bottom: 1px solid #ebeef5;
			}
		</style>
	</head>
	<body>
		<div class="layui-row">
			<div class="layui-col-md12">
				<table class="layui-hide" id="test" lay-filter="test"></table>
				<script type="text/html" id="zizeng">
					{{d.LAY_TABLE_INDEX+1}}
				</script>
				<script type="text/html" id="barDemo">
					<a class="layui-btn layui-btn-xs" lay-event="action" style="background-color: #1e9fff;">开始答题</a>
				</script>
				<script src="layui/layui.js" charset="utf-8"></script>
				<!-- 注意：如果你直接复制所有代码到本地，上述 JS 路径需要改成你本地的 -->
				<script>
					layui.use('table', function() {
						var table = layui.table;
						$(function() {
							//获取上个页面拼接的参数
							var path =  window.location.search;
							//数组获取等号右边数
							var array = path.split("=");
							// alert(array[1])
							$.ajax({
								url: 'http://localhost:8081/studentPaper/getRedis',
								async: false,
								type: "post",
								dataType: "json",
								success: function(data) {
									var item = data.data;
									for (var i = 0; i < item.length; i++) {
										var userGradeId = item[i].userGradeId;
									}
									//获取自己是几年级  拼接到下面的路径里
									var userGradeId = userGradeId;
									table.render({
										elem: '#test',
										url: 'http://localhost:8081/studentPaper/selStudentPaper?spGradeId=' +
											userGradeId + '&spSubjectId='+array[1]+'',
										title: '用户数据表',
										cols: [
											[{
												field: 'zizeng',
												width: 120,
												title: '序号',
												templet:'#zizeng'
											}, {
												field: 'spName',
												width: 960,
												title: '名称'
											}, {
												fixed: 'right',
												title: '',
												toolbar: '#barDemo',
												width: 100
											}]
										],
										page: true,
										height: 480
									});
									//监听行工具事件
									  table.on('tool(test)', function(obj){
									    var data = obj.data;
									    if (obj.event === 'action') {
											var spSubjectId = data.spSubjectId;
											var spTypeId = data.spTypeId;
											var spId = data.spId;
											var spName = data.spName;
											window.open('learn-TestPaperPage.html?spSubjectId='+spSubjectId+'&spTypeId='+spTypeId+'&spId='+spId+'&spName='+spName);
									    }
									});
								},
							})
						})
					});
					
					
				</script>
			</div>
		</div>
	</body>
</html>
